#!/bin/bash
mkdir result
riscv64-unknown-elf-gcc -g -nostdlib -c kernel/sbi.c -o result/sbi.o -mcmodel=medany -I ./include
riscv64-unknown-elf-gcc -g -nostdlib -c kernel/main.c -o result/main.o -mcmodel=medany -I ./include
riscv64-unknown-elf-gcc -g -nostdlib -c kernel/start_qemu.S -o result/start_qemu.o -mcmodel=medany -I ./include
riscv64-unknown-elf-gcc -g -nostdlib -c kernel/console.c -o result/console.o -mcmodel=medany -I ./include
riscv64-unknown-elf-gcc -g -nostdlib -c kernel/stdio.c -o result/stdio.o -mcmodel=medany -I ./include
riscv64-unknown-elf-gcc -g -nostdlib -c kernel/mmu.c -o result/mmu.o -mcmodel=medany -I ./include
riscv64-unknown-elf-gcc -g -nostdlib -c kernel/proc.c -o result/proc.o -mcmodel=medany -I ./include
riscv64-unknown-elf-gcc -g -nostdlib -c kernel/string.c -o result/string.o -mcmodel=medany -I ./include
riscv64-unknown-elf-gcc -g -nostdlib -c kernel/swtch.S -o result/swtch.o -mcmodel=medany -I ./include
riscv64-unknown-elf-gcc -g -nostdlib -c kernel/syscall.c -o result/syscall.o -mcmodel=medany -I ./include
riscv64-unknown-elf-gcc -g -nostdlib -c kernel/trampoline.S -o result/trampoline.o -mcmodel=medany -I ./include
riscv64-unknown-elf-gcc -g -nostdlib -c kernel/trap.c -o result/trap.o -mcmodel=medany -I ./include

riscv64-unknown-elf-ld  -Tlinker/qemu.ld -g result/start_qemu.o result/main.o result/stdio.o result/console.o result/sbi.o -o result/kernel.elf
rm -rf result/*.o
qemu-system-riscv64 -M virt -bios boot_loader/qemu/fw_jump.bin -kernel result/kernel.elf -smp 1 -nographic 
#qemu-system-riscv64 -M virt -bios boot_loader/qemu/fw_jump.bin -kernel result/hello.elf -smp 1 -nographic -s -S



                     
